/*
 * MyAccountListboxContentControl.cpp
 *
 *  Created on: 2011-3-11
 *      Author: 
 */

#include "MyAccountListboxContentControl.h"
#include "ProjectsDefines.h"
#include "BetterUserHBufC.h"
#include "MagazineDefines.h"
MyAccountListboxContentControl *MyAccountListboxContentControl::NewL( fEngine * aEngine, TRect rect )
{
    MyAccountListboxContentControl *self = MyAccountListboxContentControl::NewLC( aEngine, rect );

    CleanupStack::Pop( );
    return self;
}

MyAccountListboxContentControl *MyAccountListboxContentControl::NewLC( fEngine * aEngine, TRect rect )
{
    MyAccountListboxContentControl *self = new ( ELeave ) MyAccountListboxContentControl( );

    CleanupStack::PushL( self );
    self->ConstructL( aEngine, rect );
    return self;
}

MyAccountListboxContentControl::MyAccountListboxContentControl( )
{

}

void MyAccountListboxContentControl::ConstructL( fEngine * aEngine, TRect rect )
{
    BaseInit( aEngine );
    SetCtlPos( rect.iTl.iX, rect.iTl.iY );
    SetCtlSize( rect.Width( ), rect.Height( ) );

    _font = fFont::get_device_font( kContentFontHeight, EFalse, EFalse );

}

MyAccountListboxContentControl::~MyAccountListboxContentControl( )
{
    DebugLog("~");
    SAFE_DELETE( _text1 );
    SAFE_DELETE( _text2 );
    SAFE_DELETE( _text3 );
    SAFE_DELETE( _text4 );
    SAFE_DELETE( _promote );
}

void MyAccountListboxContentControl::RenderFrame( )
{
    int text_x = Left( ) + 10;
    int text_y = Top( ) + 10;
    int height = _font->HeightInPixels( ) + 10;
    if( _text1 )
    {
        iGfx->DrawString( text_x, text_y, 0x00, _font, _text1->Des( ) );
    }
    text_y += height;

    if( _text2 )
    {
        iGfx->DrawString( text_x + 16, text_y, 0x00, _font, _text2->Des( ) );
    }
    text_y += height;

    if( _text3 )
    {
        iGfx->DrawString( text_x, text_y, 0x00, _font, _text3->Des( ) );
    }
    text_y += height;

    if( _text4 )
    {
        iGfx->DrawString( text_x + 16, text_y, 0x00, _font, _text4->Des( ) );
    }
    //text_y += height;

    if( _promote )
    {
        iGfx->DrawString( Left( ) + ( ( Width( ) - _font->TextWidthInPixels( _promote->Des( ) ) >> 1 ) ), //
                Top( ) + ( ( Height( ) - _font->HeightInPixels( ) ) >> 1 ), //
                0x00, _font, _promote->Des( ) );
    }
}
void MyAccountListboxContentControl::HandleKey( f_KEY_DES * aKeyDes )
{
    if( aKeyDes->key == f_KEY_LEFT || aKeyDes->key == f_KEY_RIGHT )
    {
        if( _container )
        {
            _container->ConetentNotHandleKeyEvent( aKeyDes );
        }
    }
    else
    {

    }
}

void MyAccountListboxContentControl::SetText1( const TDesC& text )
{
    BetterUtility::Copy( _text1, text );
}
void MyAccountListboxContentControl::SetText2( const TDesC& text )
{
    BetterUtility::Copy( _text2, text );
}
void MyAccountListboxContentControl::SetText3( const TDesC& text )
{
    BetterUtility::Copy( _text3, text );
}
void MyAccountListboxContentControl::SetText4( const TDesC& text )
{
    BetterUtility::Copy( _text4, text );
}
void MyAccountListboxContentControl::SetPromote( const TDesC& promot )
{
    BetterUtility::Copy( _promote, promot );
}
